DevOps on Google Cloud Platform: Covering Docker, Jenkins, Kubernetes by Srivastava Sachin

DevOps on Google Cloud Platform: Covering Docker, Jenkins, Kubernetes by Srivastava Sachin

Author:Srivastava, Sachin [Srivastava, Sachin]
Language: eng
Format: epub
Publisher: UNKNOWN
Published: 2021-07-30T16:00:00+00:00


Creating a Continuous Delivery Project

With the Jenkins page up and running, we can finally create our CD pipeline. To try out our Jenkins feature, we create a very simple app, as follows:For trying the feature of Continuous Delivery in GCP we use the example code build by Google, this is a very simple page showing the information about the system because what we really need is understand only how to create the environment, the project is based on the gceme image present in the Google repository, gcr.io/cloud-solutions-images/gceme

For creating a CD pipeline, we first must create the different environment we use to release the software. We actually create three environments.

• Production : This is the environment in which we release the software for production.• Services : We use the service environment to describe how many layers we have. In our case, we have a back end and front end. This is not an environment like production or canary, but it is something we can use to have a more logical division of our service layers. This allows better management of that.

• Canary : This creates the canary server used for the system. Note A canary server is a server used in CD to test a feature in a real environment before it is released for production. A canary server emulates the production environment, only in a limited manner. The canary server can be used to isolate errors in code and, normally, for a limited number of users selected for production purposes. Using these servers is useful not only to uncover errors but to test the UI/UX of the application.

These environments are used to simulate the phases of CD pipeline development. To simulate them, we first must create a new namespace in Kubernetes.

kubectl create ns practical-gcp-production This command creates a new namespace in the Kubernetes cluster. We use this namespace to build our production environment. With the new namespace created, we can now create the services necessary for the code. The first service we create is for the production. The production has two services: back end and front end (see Listing 5-11 ).

Listing 5-11. Kubernetes File for Creating the Back-End Service in the Production Namespace kind: Deployment

apiVersion: extensions/v1beta1

metadata:

name: practical-gcp-backend-production

spec:

replicas: 1

template:

metadata:

name: backend

labels:

app: gceme

role: backend

env: production

spec:

containers:

- name: backend

image: gcr.io/cloud-solutions-images/gceme:1.0.0 resources:

limits:

memory: "500Mi"

cpu: "100m"

imagePullPolicy: Always

readinessProbe:

httpGet:

path: /healthz

port: 8080

command: ["sh", "-c", "app -port=8080"]

ports:

- name: backend

containerPort: 8080

The preceding is the Kubernetes file for creating the back-end service for the production. Now we can see that the service uses the applicationgceme, version 1.0.0.containers:

- name: backend

image: gcr.io/cloud-solutions-images/gceme:1.0.0

resources:

limits:

memory: "500Mi"

cpu: "100m"

imagePullPolicy: Always

The image is pulled from the Google repository and built in the Kubernetes file. The other service we need to create is the front-end service (Listing 5-12 ).

Listing 5-12. Front-End Production Service kind: Deployment

apiVersion: extensions/v1beta1

metadata:

name: practical-gcp-frontend-production

spec:

replicas:

template:

metadata:

name: frontend

labels:

app: gceme

role: frontend

env: production

spec:

containers:

- name: frontend

image: gcr.io/cloud-solutions-images/gceme:1.0.0

resources:

limits:

memory: "500Mi"

cpu: "100m"

imagePullPolicy: Always

readinessProbe:

httpGet:

path: /healthz

port: 80

command: ["sh", "-c", "app -frontend=true -backend-service=http:// gceme-backend:8080 -port=80"]

ports:

- name: frontend

containerPort: 80

These files are in the same folder, and we can use them for a deployment. A deployment is used to create and set a specific state for a pod and ReplicaSet.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.